/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DInfoSynthes.java
 *
 * Created on 18.05.2011, 20:22:40
 */

package start.gui;

import start.TestImg;

import java.awt.*;

/**
 * @author Евгений
 */
public class DInfoSynthes extends javax.swing.JDialog {
    public final static int GO_MAIN = 0;
    public final static int GO_THIS = 1;
    private int mode;

    /**
     * Creates new form DInfoSynthes
     */
    public DInfoSynthes(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }


    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel(){
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                TestImg.getInstance().drawDownPanel(g, this);

                //            g2d.dispose();
            }
        };
        bGoMain = new javax.swing.JButton();
        bThisMode = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 7));

        bGoMain.setText("Перейти в основную программу");
        bGoMain.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bGoMainActionPerformed(evt);
            }
        });
        jPanel1.add(bGoMain);

        bThisMode.setText("Продолжить работу в режиме");
        bThisMode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bThisModeActionPerformed(evt);
            }
        });
        jPanel1.add(bThisMode);

        getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("jLabel1");
        jLabel1.setMaximumSize(new java.awt.Dimension(41, 70));
        jLabel1.setMinimumSize(new java.awt.Dimension(41, 70));
        jLabel1.setPreferredSize(new java.awt.Dimension(41, 70));
        getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER);

        jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.LINE_AXIS));
        getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_START);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bGoMainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bGoMainActionPerformed
        this.mode = GO_MAIN;
        setVisible(false);
    }//GEN-LAST:event_bGoMainActionPerformed

    private void bThisModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bThisModeActionPerformed
        this.mode = GO_THIS;
        setVisible(false);
    }//GEN-LAST:event_bThisModeActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowClosed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowClosing

    public int open() {
        jLabel1.setText("Подождите выполняется синтез структуры...");
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/loading1.gif")));
        bGoMain.setEnabled(false);
        bThisMode.setEnabled(false);
        setVisible(true);
        return mode;
    }

    public void enabledButton() {
        jLabel1.setText("Структура синтезирована. Выберите режим?");
        jLabel1.setIcon(null);
        bGoMain.setEnabled(true);
        bThisMode.setEnabled(true);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                DInfoSynthes dialog = new DInfoSynthes(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bGoMain;
    private javax.swing.JButton bThisMode;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    // End of variables declaration//GEN-END:variables

}
